{#
    @profile_type   arguments

    all             mail, profile_type, [msg,]
    @general        profile, languagemaps,
    @domains        allDomains, managedDomains,
    @password       min_passwd_length, max_passwd_length,
#}
{% extends "layout.html" %}
{% from "macros/general.html" import
                display_subnav,
                set_account_status_img,
                display_account_status,
                display_input_cn,
                display_preferred_language,
                display_reset_password,
                display_button_submit,
                with context
                %}

{% from "macros/msgHandlers.html" import adminMsgHandler with context %}

{% block title %}{{ _('Edit account profile') }}{% endblock %}
{% block navlinks_active_admins %}class="active"{% endblock %}

{% block breadcrumb %}
    {% set crumbs = [
            (ctx.homepath + '/admins', _('All admins'),),
            (None, _('Profile of admin:') + ' ' + mail,),
            ]
            %}
    {{ display_subnav(crumbs) }}
{% endblock %}


{% block main %}

{# Show system message #}
{{ adminMsgHandler(msg) }}

{% set navlinks = [
                ('general', _('General'), []),
                ('password', _('Password'), []),
                ]
                %}

<div class="content-box">
    <div class="box-body">
        <div class="box-header clear">
            <ul class="tabs clear">
                {% for nav in navlinks %}
                    {% if not false in nav[2] and not none in nav[2] %}
                        <li><a href="#profile_{{ nav[0] }}">{{ nav[1] }}</a></li>
                    {% endif %}
                {% endfor %}
            </ul>

            <h2>{{ _('Profile of admin:') }} {{ mail }}</h2>
        </div>

        <div class="box-wrap clear">
            <div id="profile_general">
                <form method="post" action="{{ctx.homepath}}/profile/admin/general/{{mail}}">
                    {% if profile.language != '' %}
                        {% set preferredLanguage = profile.language |string |e %}
                    {% else %}
                        {% set preferredLanguage = 'en_US' %}
                    {% endif %}

                    <div class="columns clear">
                        <div class="col2-3">
                            {% if session.get('domainGlobalAdmin') is sameas true %}
                                {{ display_account_status(profile.active) }}
                                <div class="bt-space0">&nbsp;</div>
                            {% endif %}

                            {{ display_input_cn(cn=profile.name, accountType='admin') }}
                            {{ display_preferred_language(value=preferredLanguage, languagemaps=languagemaps) }}
                        </div>
                    </div>{# .columns #}

                    {{ display_button_submit() }}
                </form>
            </div>

            <div id="profile_password">
                <form method="post" action="{{ctx.homepath}}/profile/admin/password/{{mail}}">
                    {% if session.get('domainGlobalAdmin') is sameas true %}
                        {{ display_reset_password(
                                min_passwd_length=min_passwd_length,
                                max_passwd_length=max_passwd_length,
                                show_confirmpw=true,
                                )
                                }}
                    {% else %}
                        {{ display_reset_password(
                                min_passwd_length=min_passwd_length,
                                max_passwd_length=max_passwd_length,
                                show_oldpw=true,
                                show_confirmpw=true,
                                )
                                }}
                    {% endif %}

                    {{ display_button_submit() }}
                </form>
            </div>
        </div>{# .box-wrap #}
    </div>{# .box-body #}
</div>{#-- .content-box --#}
{% endblock main %}
